package c.c.b.a.b.a.c;

import c.c.b.a.b.a.e;
import c.c.b.a.b.a.e.d;
import c.c.b.a.b.b;
import c.c.b.a.b.f;
import c.c.b.a.b.j;
import c.c.b.a.b.m;
import c.c.b.a.b.s;
import java.io.IOException;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.net.Socket;
import java.util.Objects;

/* compiled from: StreamAllocation */
public final class g {
    public final b a;
    public c.c.b.a.b.a.c.f.a b;
    public f c;
    public final m d;
    public final j e;
    public final s f;
    public final Object g;
    public final f h;
    public int i;
    public c j;
    public boolean k;
    public boolean l;
    public d m;

    /* compiled from: StreamAllocation */
    public static final class a extends WeakReference<g> {
        public final Object a;

        public a(g gVar, Object obj) {
            super(gVar);
            this.a = obj;
        }
    }

    public g(m mVar, b bVar, j jVar, s sVar, Object obj) {
        this.d = mVar;
        this.a = bVar;
        this.e = jVar;
        this.f = sVar;
        Objects.requireNonNull((c.c.b.a.b.z.a) c.c.b.a.b.a.b.a);
        this.h = new f(bVar, mVar.e, jVar, sVar);
        this.g = obj;
    }

    /* JADX WARNING: Removed duplicated region for block: B:111:0x020b  */
    /* JADX WARNING: Removed duplicated region for block: B:133:0x0277  */
    /* JADX WARNING: Removed duplicated region for block: B:131:0x0271  */
    public final c.c.b.a.b.a.c.c a(int r17, int r18, int r19, boolean r20) throws java.io.IOException {
        /*
        r16 = this;
        r1 = r16;
        r2 = r1.d;
        monitor-enter(r2);
        r0 = r1.l;	 Catch:{ all -> 0x02ea }
        if (r0 != 0) goto L_0x02e2;
    L_0x0009:
        r0 = r1.m;	 Catch:{ all -> 0x02ea }
        if (r0 != 0) goto L_0x02da;
    L_0x000d:
        r0 = r1.j;	 Catch:{ all -> 0x02ea }
        r3 = 0;
        r4 = 0;
        r5 = 1;
        if (r0 == 0) goto L_0x001d;
    L_0x0014:
        r6 = r0.k;	 Catch:{ all -> 0x02ea }
        if (r6 == 0) goto L_0x001d;
    L_0x0018:
        r6 = r1.c(r4, r4, r5);	 Catch:{ all -> 0x02ea }
        goto L_0x001e;
    L_0x001d:
        r6 = r3;
    L_0x001e:
        r7 = r1.j;	 Catch:{ all -> 0x02ea }
        if (r7 == 0) goto L_0x0024;
    L_0x0022:
        r0 = r3;
        goto L_0x0025;
    L_0x0024:
        r7 = r3;
    L_0x0025:
        r8 = r1.k;	 Catch:{ all -> 0x02ea }
        if (r8 != 0) goto L_0x002a;
    L_0x0029:
        r0 = r3;
    L_0x002a:
        if (r7 != 0) goto L_0x003d;
    L_0x002c:
        r8 = c.c.b.a.b.a.b.a;	 Catch:{ all -> 0x02ea }
        r9 = r1.d;	 Catch:{ all -> 0x02ea }
        r10 = r1.a;	 Catch:{ all -> 0x02ea }
        r8.a(r9, r10, r1, r3);	 Catch:{ all -> 0x02ea }
        r8 = r1.j;	 Catch:{ all -> 0x02ea }
        if (r8 == 0) goto L_0x003b;
    L_0x0039:
        r7 = 1;
        goto L_0x0040;
    L_0x003b:
        r3 = r1.c;	 Catch:{ all -> 0x02ea }
    L_0x003d:
        r8 = 0;
        r8 = r7;
        r7 = 0;
    L_0x0040:
        monitor-exit(r2);	 Catch:{ all -> 0x02ea }
        c.c.b.a.b.a.e.o(r6);
        if (r0 == 0) goto L_0x004b;
    L_0x0046:
        r0 = r1.f;
        java.util.Objects.requireNonNull(r0);
    L_0x004b:
        if (r7 == 0) goto L_0x0052;
    L_0x004d:
        r0 = r1.f;
        java.util.Objects.requireNonNull(r0);
    L_0x0052:
        if (r8 == 0) goto L_0x0055;
    L_0x0054:
        return r8;
    L_0x0055:
        if (r3 != 0) goto L_0x0207;
    L_0x0057:
        r0 = r1.b;
        if (r0 == 0) goto L_0x0061;
    L_0x005b:
        r0 = r0.a();
        if (r0 != 0) goto L_0x0207;
    L_0x0061:
        r0 = r1.h;
        r2 = r0.b();
        if (r2 == 0) goto L_0x0201;
    L_0x0069:
        r2 = new java.util.ArrayList;
        r2.<init>();
    L_0x006e:
        r6 = r0.c();
        if (r6 == 0) goto L_0x01e8;
    L_0x0074:
        r6 = r0.c();
        r9 = "No route to ";
        if (r6 == 0) goto L_0x01c7;
    L_0x007c:
        r6 = r0.e;
        r10 = r0.f;
        r11 = r10 + 1;
        r0.f = r11;
        r6 = r6.get(r10);
        r6 = (java.net.Proxy) r6;
        r10 = new java.util.ArrayList;
        r10.<init>();
        r0.g = r10;
        r10 = r6.type();
        r11 = java.net.Proxy.Type.DIRECT;
        if (r10 == r11) goto L_0x00d7;
    L_0x0099:
        r10 = r6.type();
        r11 = java.net.Proxy.Type.SOCKS;
        if (r10 != r11) goto L_0x00a2;
    L_0x00a1:
        goto L_0x00d7;
    L_0x00a2:
        r10 = r6.address();
        r11 = r10 instanceof java.net.InetSocketAddress;
        if (r11 == 0) goto L_0x00c0;
    L_0x00aa:
        r10 = (java.net.InetSocketAddress) r10;
        r11 = r10.getAddress();
        if (r11 != 0) goto L_0x00b7;
    L_0x00b2:
        r11 = r10.getHostName();
        goto L_0x00bb;
    L_0x00b7:
        r11 = r11.getHostAddress();
    L_0x00bb:
        r10 = r10.getPort();
        goto L_0x00df;
    L_0x00c0:
        r0 = new java.lang.IllegalArgumentException;
        r2 = "Proxy.address() is not an InetSocketAddress: ";
        r2 = c.b.a.a.a.g(r2);
        r3 = r10.getClass();
        r2.append(r3);
        r2 = r2.toString();
        r0.<init>(r2);
        throw r0;
    L_0x00d7:
        r10 = r0.a;
        r10 = r10.a;
        r11 = r10.d;
        r10 = r10.e;
    L_0x00df:
        if (r10 < r5) goto L_0x01a5;
    L_0x00e1:
        r12 = 65535; // 0xffff float:9.1834E-41 double:3.23786E-319;
        if (r10 > r12) goto L_0x01a5;
    L_0x00e6:
        r9 = r6.type();
        r12 = java.net.Proxy.Type.SOCKS;
        if (r9 != r12) goto L_0x00f8;
    L_0x00ee:
        r9 = r0.g;
        r10 = java.net.InetSocketAddress.createUnresolved(r11, r10);
        r9.add(r10);
        goto L_0x0135;
    L_0x00f8:
        r9 = r0.d;
        java.util.Objects.requireNonNull(r9);
        r9 = r0.a;
        r9 = r9.b;
        r9 = (c.c.b.a.b.r.a) r9;
        java.util.Objects.requireNonNull(r9);
        if (r11 == 0) goto L_0x019d;
    L_0x0108:
        r9 = java.net.InetAddress.getAllByName(r11);	 Catch:{ NullPointerException -> 0x018d }
        r9 = java.util.Arrays.asList(r9);	 Catch:{ NullPointerException -> 0x018d }
        r12 = r9.isEmpty();
        if (r12 != 0) goto L_0x016f;
    L_0x0116:
        r11 = r0.d;
        java.util.Objects.requireNonNull(r11);
        r11 = r9.size();
        r12 = 0;
    L_0x0120:
        if (r12 >= r11) goto L_0x0135;
    L_0x0122:
        r13 = r9.get(r12);
        r13 = (java.net.InetAddress) r13;
        r14 = r0.g;
        r15 = new java.net.InetSocketAddress;
        r15.<init>(r13, r10);
        r14.add(r15);
        r12 = r12 + 1;
        goto L_0x0120;
    L_0x0135:
        r9 = r0.g;
        r9 = r9.size();
        r10 = 0;
    L_0x013c:
        if (r10 >= r9) goto L_0x0168;
    L_0x013e:
        r11 = new c.c.b.a.b.f;
        r12 = r0.a;
        r13 = r0.g;
        r13 = r13.get(r10);
        r13 = (java.net.InetSocketAddress) r13;
        r11.m940init(r12, r6, r13);
        r12 = r0.b;
        monitor-enter(r12);
        r13 = r12.a;	 Catch:{ all -> 0x0165 }
        r13 = r13.contains(r11);	 Catch:{ all -> 0x0165 }
        monitor-exit(r12);
        if (r13 == 0) goto L_0x015f;
    L_0x0159:
        r12 = r0.h;
        r12.add(r11);
        goto L_0x0162;
    L_0x015f:
        r2.add(r11);
    L_0x0162:
        r10 = r10 + 1;
        goto L_0x013c;
    L_0x0165:
        r0 = move-exception;
        monitor-exit(r12);
        throw r0;
    L_0x0168:
        r6 = r2.isEmpty();
        if (r6 != 0) goto L_0x006e;
    L_0x016e:
        goto L_0x01e8;
    L_0x016f:
        r2 = new java.net.UnknownHostException;
        r3 = new java.lang.StringBuilder;
        r3.<init>();
        r0 = r0.a;
        r0 = r0.b;
        r3.append(r0);
        r0 = " returned no addresses for ";
        r3.append(r0);
        r3.append(r11);
        r0 = r3.toString();
        r2.<init>(r0);
        throw r2;
    L_0x018d:
        r0 = move-exception;
        r2 = new java.net.UnknownHostException;
        r3 = "Broken system behaviour for dns lookup of ";
        r3 = c.b.a.a.a.D(r3, r11);
        r2.<init>(r3);
        r2.initCause(r0);
        throw r2;
    L_0x019d:
        r0 = new java.net.UnknownHostException;
        r2 = "hostname == null";
        r0.<init>(r2);
        throw r0;
    L_0x01a5:
        r0 = new java.net.SocketException;
        r2 = new java.lang.StringBuilder;
        r2.<init>();
        r2.append(r9);
        r2.append(r11);
        r3 = ":";
        r2.append(r3);
        r2.append(r10);
        r3 = "; port is out of range";
        r2.append(r3);
        r2 = r2.toString();
        r0.<init>(r2);
        throw r0;
    L_0x01c7:
        r2 = new java.net.SocketException;
        r3 = c.b.a.a.a.g(r9);
        r4 = r0.a;
        r4 = r4.a;
        r4 = r4.d;
        r3.append(r4);
        r4 = "; exhausted proxy configurations: ";
        r3.append(r4);
        r0 = r0.e;
        r3.append(r0);
        r0 = r3.toString();
        r2.<init>(r0);
        throw r2;
    L_0x01e8:
        r6 = r2.isEmpty();
        if (r6 == 0) goto L_0x01f8;
    L_0x01ee:
        r6 = r0.h;
        r2.addAll(r6);
        r0 = r0.h;
        r0.clear();
    L_0x01f8:
        r0 = new c.c.b.a.b.a.c.f$a;
        r0.m877init(r2);
        r1.b = r0;
        r0 = 1;
        goto L_0x0208;
    L_0x0201:
        r0 = new java.util.NoSuchElementException;
        r0.<init>();
        throw r0;
    L_0x0207:
        r0 = 0;
    L_0x0208:
        r6 = r1.d;
        monitor-enter(r6);
        if (r0 == 0) goto L_0x023e;
    L_0x020d:
        r0 = r1.b;	 Catch:{ all -> 0x023b }
        java.util.Objects.requireNonNull(r0);	 Catch:{ all -> 0x023b }
        r2 = new java.util.ArrayList;	 Catch:{ all -> 0x023b }
        r0 = r0.a;	 Catch:{ all -> 0x023b }
        r2.<init>(r0);	 Catch:{ all -> 0x023b }
        r0 = r2.size();	 Catch:{ all -> 0x023b }
        r9 = 0;
    L_0x021e:
        if (r9 >= r0) goto L_0x023e;
    L_0x0220:
        r10 = r2.get(r9);	 Catch:{ all -> 0x023b }
        r10 = (c.c.b.a.b.f) r10;	 Catch:{ all -> 0x023b }
        r11 = c.c.b.a.b.a.b.a;	 Catch:{ all -> 0x023b }
        r12 = r1.d;	 Catch:{ all -> 0x023b }
        r13 = r1.a;	 Catch:{ all -> 0x023b }
        r11.a(r12, r13, r1, r10);	 Catch:{ all -> 0x023b }
        r11 = r1.j;	 Catch:{ all -> 0x023b }
        if (r11 == 0) goto L_0x0238;
    L_0x0233:
        r1.c = r10;	 Catch:{ all -> 0x023b }
        r7 = 1;
        r8 = r11;
        goto L_0x023e;
    L_0x0238:
        r9 = r9 + 1;
        goto L_0x021e;
    L_0x023b:
        r0 = move-exception;
        goto L_0x02d8;
    L_0x023e:
        if (r7 != 0) goto L_0x026e;
    L_0x0240:
        if (r3 != 0) goto L_0x0260;
    L_0x0242:
        r0 = r1.b;	 Catch:{ all -> 0x023b }
        r2 = r0.a();	 Catch:{ all -> 0x023b }
        if (r2 == 0) goto L_0x025a;
    L_0x024a:
        r2 = r0.a;	 Catch:{ all -> 0x023b }
        r3 = r0.b;	 Catch:{ all -> 0x023b }
        r8 = r3 + 1;
        r0.b = r8;	 Catch:{ all -> 0x023b }
        r0 = r2.get(r3);	 Catch:{ all -> 0x023b }
        r3 = r0;
        r3 = (c.c.b.a.b.f) r3;	 Catch:{ all -> 0x023b }
        goto L_0x0260;
    L_0x025a:
        r0 = new java.util.NoSuchElementException;	 Catch:{ all -> 0x023b }
        r0.<init>();	 Catch:{ all -> 0x023b }
        throw r0;	 Catch:{ all -> 0x023b }
    L_0x0260:
        r1.c = r3;	 Catch:{ all -> 0x023b }
        r1.i = r4;	 Catch:{ all -> 0x023b }
        r8 = new c.c.b.a.b.a.c.c;	 Catch:{ all -> 0x023b }
        r0 = r1.d;	 Catch:{ all -> 0x023b }
        r8.m5297init(r0, r3);	 Catch:{ all -> 0x023b }
        r1.d(r8, r4);	 Catch:{ all -> 0x023b }
    L_0x026e:
        monitor-exit(r6);	 Catch:{ all -> 0x023b }
        if (r7 == 0) goto L_0x0277;
    L_0x0271:
        r0 = r1.f;
        java.util.Objects.requireNonNull(r0);
        return r8;
    L_0x0277:
        r14 = r1.e;
        r15 = r1.f;
        r9 = r8;
        r10 = r17;
        r11 = r18;
        r12 = r19;
        r13 = r20;
        r9.e(r10, r11, r12, r13, r14, r15);
        r0 = c.c.b.a.b.a.b.a;
        r2 = r1.d;
        r0 = (c.c.b.a.b.z.a) r0;
        java.util.Objects.requireNonNull(r0);
        r0 = r2.e;
        r2 = r8.c;
        r0.a(r2);
        r2 = r1.d;
        monitor-enter(r2);
        r1.k = r5;	 Catch:{ all -> 0x02d5 }
        r0 = c.c.b.a.b.a.b.a;	 Catch:{ all -> 0x02d5 }
        r3 = r1.d;	 Catch:{ all -> 0x02d5 }
        r0 = (c.c.b.a.b.z.a) r0;	 Catch:{ all -> 0x02d5 }
        java.util.Objects.requireNonNull(r0);	 Catch:{ all -> 0x02d5 }
        r0 = r3.f;	 Catch:{ all -> 0x02d5 }
        if (r0 != 0) goto L_0x02b2;
    L_0x02a9:
        r3.f = r5;	 Catch:{ all -> 0x02d5 }
        r0 = c.c.b.a.b.m.g;	 Catch:{ all -> 0x02d5 }
        r4 = r3.c;	 Catch:{ all -> 0x02d5 }
        r0.execute(r4);	 Catch:{ all -> 0x02d5 }
    L_0x02b2:
        r0 = r3.d;	 Catch:{ all -> 0x02d5 }
        r0.add(r8);	 Catch:{ all -> 0x02d5 }
        r0 = r8.j();	 Catch:{ all -> 0x02d5 }
        if (r0 == 0) goto L_0x02ca;
    L_0x02bd:
        r0 = c.c.b.a.b.a.b.a;	 Catch:{ all -> 0x02d5 }
        r3 = r1.d;	 Catch:{ all -> 0x02d5 }
        r4 = r1.a;	 Catch:{ all -> 0x02d5 }
        r0 = r0.b(r3, r4, r1);	 Catch:{ all -> 0x02d5 }
        r8 = r1.j;	 Catch:{ all -> 0x02d5 }
        goto L_0x02cb;
    L_0x02ca:
        r0 = 0;
    L_0x02cb:
        monitor-exit(r2);	 Catch:{ all -> 0x02d5 }
        c.c.b.a.b.a.e.o(r0);
        r0 = r1.f;
        java.util.Objects.requireNonNull(r0);
        return r8;
    L_0x02d5:
        r0 = move-exception;
        monitor-exit(r2);	 Catch:{ all -> 0x02d5 }
        throw r0;
    L_0x02d8:
        monitor-exit(r6);	 Catch:{ all -> 0x023b }
        throw r0;
    L_0x02da:
        r0 = new java.lang.IllegalStateException;	 Catch:{ all -> 0x02ea }
        r3 = "codec != null";
        r0.<init>(r3);	 Catch:{ all -> 0x02ea }
        throw r0;	 Catch:{ all -> 0x02ea }
    L_0x02e2:
        r0 = new java.lang.IllegalStateException;	 Catch:{ all -> 0x02ea }
        r3 = "released";
        r0.<init>(r3);	 Catch:{ all -> 0x02ea }
        throw r0;	 Catch:{ all -> 0x02ea }
    L_0x02ea:
        r0 = move-exception;
        monitor-exit(r2);	 Catch:{ all -> 0x02ea }
        throw r0;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.c.b.a.b.a.c.g.a(int, int, int, boolean):c.c.b.a.b.a.c.c");
    }

    /* JADX WARNING: Removed duplicated region for block: B:47:0x0065 A:{SYNTHETIC} */
    /* JADX WARNING: Removed duplicated region for block: B:40:0x0061 A:{LOOP_END, LOOP:0: B:0:0x0000->B:40:0x0061} */
    /* JADX WARNING: Missing block: B:8:0x000e, code skipped:
            r2 = 0;
     */
    /* JADX WARNING: Missing block: B:9:0x0015, code skipped:
            if (r0.e.isClosed() != false) goto L_0x005f;
     */
    /* JADX WARNING: Missing block: B:11:0x001d, code skipped:
            if (r0.e.isInputShutdown() != false) goto L_0x005f;
     */
    /* JADX WARNING: Missing block: B:13:0x0025, code skipped:
            if (r0.e.isOutputShutdown() == false) goto L_0x0028;
     */
    /* JADX WARNING: Missing block: B:14:0x0028, code skipped:
            r1 = r0.h;
     */
    /* JADX WARNING: Missing block: B:15:0x002b, code skipped:
            if (r1 == null) goto L_0x0036;
     */
    /* JADX WARNING: Missing block: B:16:0x002d, code skipped:
            monitor-enter(r1);
     */
    /* JADX WARNING: Missing block: B:18:?, code skipped:
            r2 = r1.g;
     */
    /* JADX WARNING: Missing block: B:19:0x0030, code skipped:
            monitor-exit(r1);
     */
    /* JADX WARNING: Missing block: B:20:0x0031, code skipped:
            r2 = r2 ^ 1;
     */
    /* JADX WARNING: Missing block: B:24:0x0036, code skipped:
            if (r11 == false) goto L_0x005e;
     */
    /* JADX WARNING: Missing block: B:26:?, code skipped:
            r1 = r0.e.getSoTimeout();
     */
    /* JADX WARNING: Missing block: B:28:?, code skipped:
            r0.e.setSoTimeout(1);
     */
    /* JADX WARNING: Missing block: B:29:0x0049, code skipped:
            if (r0.i.e() == false) goto L_0x0051;
     */
    /* JADX WARNING: Missing block: B:31:?, code skipped:
            r0.e.setSoTimeout(r1);
     */
    /* JADX WARNING: Missing block: B:32:0x0051, code skipped:
            r0.e.setSoTimeout(r1);
     */
    /* JADX WARNING: Missing block: B:34:0x0058, code skipped:
            r0.e.setSoTimeout(r1);
     */
    public final c.c.b.a.b.a.c.c b(int r7, int r8, int r9, boolean r10, boolean r11) throws java.io.IOException {
        /*
        r6 = this;
    L_0x0000:
        r0 = r6.a(r7, r8, r9, r10);
        r1 = r6.d;
        monitor-enter(r1);
        r2 = r0.l;	 Catch:{ all -> 0x0066 }
        if (r2 != 0) goto L_0x000d;
    L_0x000b:
        monitor-exit(r1);	 Catch:{ all -> 0x0066 }
        return r0;
    L_0x000d:
        monitor-exit(r1);	 Catch:{ all -> 0x0066 }
        r1 = r0.e;
        r1 = r1.isClosed();
        r2 = 0;
        if (r1 != 0) goto L_0x005f;
    L_0x0017:
        r1 = r0.e;
        r1 = r1.isInputShutdown();
        if (r1 != 0) goto L_0x005f;
    L_0x001f:
        r1 = r0.e;
        r1 = r1.isOutputShutdown();
        if (r1 == 0) goto L_0x0028;
    L_0x0027:
        goto L_0x005f;
    L_0x0028:
        r1 = r0.h;
        r3 = 1;
        if (r1 == 0) goto L_0x0036;
    L_0x002d:
        monitor-enter(r1);
        r2 = r1.g;	 Catch:{ all -> 0x0033 }
        monitor-exit(r1);
        r2 = r2 ^ r3;
        goto L_0x005f;
    L_0x0033:
        r7 = move-exception;
        monitor-exit(r1);
        throw r7;
    L_0x0036:
        if (r11 == 0) goto L_0x005e;
    L_0x0038:
        r1 = r0.e;	 Catch:{ SocketTimeoutException -> 0x005e, IOException -> 0x005f }
        r1 = r1.getSoTimeout();	 Catch:{ SocketTimeoutException -> 0x005e, IOException -> 0x005f }
        r4 = r0.e;	 Catch:{ all -> 0x0057 }
        r4.setSoTimeout(r3);	 Catch:{ all -> 0x0057 }
        r4 = r0.i;	 Catch:{ all -> 0x0057 }
        r4 = r4.e();	 Catch:{ all -> 0x0057 }
        if (r4 == 0) goto L_0x0051;
    L_0x004b:
        r4 = r0.e;	 Catch:{ SocketTimeoutException -> 0x005e, IOException -> 0x005f }
        r4.setSoTimeout(r1);	 Catch:{ SocketTimeoutException -> 0x005e, IOException -> 0x005f }
        goto L_0x005f;
    L_0x0051:
        r4 = r0.e;	 Catch:{ SocketTimeoutException -> 0x005e, IOException -> 0x005f }
        r4.setSoTimeout(r1);	 Catch:{ SocketTimeoutException -> 0x005e, IOException -> 0x005f }
        goto L_0x005e;
    L_0x0057:
        r4 = move-exception;
        r5 = r0.e;	 Catch:{ SocketTimeoutException -> 0x005e, IOException -> 0x005f }
        r5.setSoTimeout(r1);	 Catch:{ SocketTimeoutException -> 0x005e, IOException -> 0x005f }
        throw r4;	 Catch:{ SocketTimeoutException -> 0x005e, IOException -> 0x005f }
    L_0x005e:
        r2 = 1;
    L_0x005f:
        if (r2 != 0) goto L_0x0065;
    L_0x0061:
        r6.i();
        goto L_0x0000;
    L_0x0065:
        return r0;
    L_0x0066:
        r7 = move-exception;
        monitor-exit(r1);	 Catch:{ all -> 0x0066 }
        throw r7;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.c.b.a.b.a.c.g.b(int, int, int, boolean, boolean):c.c.b.a.b.a.c.c");
    }

    public final Socket c(boolean z, boolean z2, boolean z3) {
        if (z3) {
            this.m = null;
        }
        z3 = true;
        if (z2) {
            this.l = true;
        }
        c cVar = this.j;
        if (cVar == null) {
            return null;
        }
        if (z) {
            cVar.k = true;
        }
        if (this.m != null) {
            return null;
        }
        if (!this.l && !cVar.k) {
            return null;
        }
        int size = cVar.n.size();
        for (int i = 0; i < size; i++) {
            if (((Reference) cVar.n.get(i)).get() == this) {
                Socket socket;
                cVar.n.remove(i);
                if (this.j.n.isEmpty()) {
                    this.j.o = System.nanoTime();
                    c.c.b.a.b.a.b bVar = c.c.b.a.b.a.b.a;
                    m mVar = this.d;
                    c cVar2 = this.j;
                    Objects.requireNonNull((c.c.b.a.b.z.a) bVar);
                    Objects.requireNonNull(mVar);
                    if (cVar2.k || mVar.a == 0) {
                        mVar.d.remove(cVar2);
                    } else {
                        mVar.notifyAll();
                        z3 = false;
                    }
                    if (z3) {
                        socket = this.j.e;
                        this.j = null;
                        return socket;
                    }
                }
                socket = null;
                this.j = null;
                return socket;
            }
        }
        throw new IllegalStateException();
    }

    public void d(c cVar, boolean z) {
        if (this.j == null) {
            this.j = cVar;
            this.k = z;
            cVar.n.add(new a(this, this.g));
            return;
        }
        throw new IllegalStateException();
    }

    /* JADX WARNING: Removed duplicated region for block: B:29:0x004e  */
    /* JADX WARNING: Removed duplicated region for block: B:29:0x004e  */
    public void e(java.io.IOException r7) {
        /*
        r6 = this;
        r0 = r6.d;
        monitor-enter(r0);
        r1 = r7 instanceof c.c.b.a.b.a.h.w;	 Catch:{ all -> 0x0060 }
        r2 = 0;
        r3 = 0;
        r4 = 1;
        if (r1 == 0) goto L_0x0020;
    L_0x000a:
        r7 = (c.c.b.a.b.a.h.w) r7;	 Catch:{ all -> 0x0060 }
        r7 = r7.a;	 Catch:{ all -> 0x0060 }
        r1 = c.c.b.a.b.a.h.b.REFUSED_STREAM;	 Catch:{ all -> 0x0060 }
        if (r7 != r1) goto L_0x0017;
    L_0x0012:
        r5 = r6.i;	 Catch:{ all -> 0x0060 }
        r5 = r5 + r4;
        r6.i = r5;	 Catch:{ all -> 0x0060 }
    L_0x0017:
        if (r7 != r1) goto L_0x001d;
    L_0x0019:
        r7 = r6.i;	 Catch:{ all -> 0x0060 }
        if (r7 <= r4) goto L_0x0043;
    L_0x001d:
        r6.c = r3;	 Catch:{ all -> 0x0060 }
        goto L_0x0041;
    L_0x0020:
        r1 = r6.j;	 Catch:{ all -> 0x0060 }
        if (r1 == 0) goto L_0x0043;
    L_0x0024:
        r1 = r1.j();	 Catch:{ all -> 0x0060 }
        if (r1 == 0) goto L_0x002e;
    L_0x002a:
        r1 = r7 instanceof c.c.b.a.b.a.h.a;	 Catch:{ all -> 0x0060 }
        if (r1 == 0) goto L_0x0043;
    L_0x002e:
        r1 = r6.j;	 Catch:{ all -> 0x0060 }
        r1 = r1.l;	 Catch:{ all -> 0x0060 }
        if (r1 != 0) goto L_0x0041;
    L_0x0034:
        r1 = r6.c;	 Catch:{ all -> 0x0060 }
        if (r1 == 0) goto L_0x003f;
    L_0x0038:
        if (r7 == 0) goto L_0x003f;
    L_0x003a:
        r5 = r6.h;	 Catch:{ all -> 0x0060 }
        r5.a(r1, r7);	 Catch:{ all -> 0x0060 }
    L_0x003f:
        r6.c = r3;	 Catch:{ all -> 0x0060 }
    L_0x0041:
        r7 = 1;
        goto L_0x0044;
    L_0x0043:
        r7 = 0;
    L_0x0044:
        r1 = r6.j;	 Catch:{ all -> 0x0060 }
        r7 = r6.c(r7, r2, r4);	 Catch:{ all -> 0x0060 }
        r2 = r6.j;	 Catch:{ all -> 0x0060 }
        if (r2 != 0) goto L_0x0054;
    L_0x004e:
        r2 = r6.k;	 Catch:{ all -> 0x0060 }
        if (r2 != 0) goto L_0x0053;
    L_0x0052:
        goto L_0x0054;
    L_0x0053:
        r3 = r1;
    L_0x0054:
        monitor-exit(r0);	 Catch:{ all -> 0x0060 }
        c.c.b.a.b.a.e.o(r7);
        if (r3 == 0) goto L_0x005f;
    L_0x005a:
        r7 = r6.f;
        java.util.Objects.requireNonNull(r7);
    L_0x005f:
        return;
    L_0x0060:
        r7 = move-exception;
        monitor-exit(r0);	 Catch:{ all -> 0x0060 }
        throw r7;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.c.b.a.b.a.c.g.e(java.io.IOException):void");
    }

    public void f(boolean z, d dVar, long j, IOException iOException) {
        c cVar;
        Socket c;
        boolean z2;
        Objects.requireNonNull(this.f);
        synchronized (this.d) {
            if (dVar != null) {
                if (dVar == this.m) {
                    if (!z) {
                        cVar = this.j;
                        cVar.l++;
                    }
                    cVar = this.j;
                    c = c(z, false, true);
                    if (this.j != null) {
                        cVar = null;
                    }
                    z2 = this.l;
                }
            }
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append("expected ");
            stringBuilder.append(this.m);
            stringBuilder.append(" but was ");
            stringBuilder.append(dVar);
            throw new IllegalStateException(stringBuilder.toString());
        }
        e.o(c);
        if (cVar != null) {
            Objects.requireNonNull(this.f);
        }
        if (iOException != null) {
            Objects.requireNonNull(this.f);
        } else if (z2) {
            Objects.requireNonNull(this.f);
        }
    }

    public synchronized c g() {
        return this.j;
    }

    public void h() {
        c cVar;
        Socket c;
        synchronized (this.d) {
            cVar = this.j;
            c = c(false, true, false);
            if (this.j != null) {
                cVar = null;
            }
        }
        e.o(c);
        if (cVar != null) {
            Objects.requireNonNull(this.f);
        }
    }

    public void i() {
        c cVar;
        Socket c;
        synchronized (this.d) {
            cVar = this.j;
            c = c(true, false, false);
            if (this.j != null) {
                cVar = null;
            }
        }
        e.o(c);
        if (cVar != null) {
            Objects.requireNonNull(this.f);
        }
    }

    public String toString() {
        c g = g();
        return g != null ? g.toString() : this.a.toString();
    }
}
